﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using PServiceBus.Gateway.Interfaces.Commands;
using Phoenix.ZeroMQConnectors;

namespace PServiceBus.Gateway.ZeroMQ.Commands {

    public sealed class ZeroMQRouterMessage : RouterMessage, IZeroMQCommand {
        #region IZeroMQCommand Members

        public bool IsAsync { get; set; }

        public string Key { get; set; }

        public ZeroPatternType Pattern { get; set; }

        #endregion

        public static ZeroMQRouterMessage New(Guid? id = null, bool decrement = false, bool async = true) {
            var stack = new StackTrace(false);
            var commandName = stack.GetFrame(1).GetMethod().Name;
            return new ZeroMQRouterMessage()
            {
                ID = id ?? Guid.Empty,
                Decrement = decrement,
                CommandName = commandName,
                IsAsync = async
            };
        }
    }
}
